
class P639_39643 {

	static String readLn() {
		String newLine = System.getProperty("line.separator");
		StringBuffer buffer = new StringBuffer();
		int car = -1;
		try {
			car = System.in.read();
			while ((car > 0) && (car != newLine.charAt(0))) {
				buffer.append((char) car);
				car = System.in.read();
			}
			if (car == newLine.charAt(0))
				System.in.skip(newLine.length() - 1);
		} catch (java.io.IOException e) {
			return (null);
		}
		if ((car < 0) && (buffer.length() == 0))
			return (null);
		return (buffer.toString()).trim();
	}

	
	static int length, n, walls;
	
	static char[][] positions, table;
	
	public static void main(String[] args) {
		
		while (true) {
			n = Integer.parseInt(readLn());
			
			if (n == 0) break;
			
			positions = new char[n][n];
			table = new char[n][n];
			walls = 0;
			for (int k = 0; k < n; k++) {
				String line = readLn();
				for (int j = 0; j < n; j++) {
					table[k][j] = line.charAt(j);
					if (table[k][j] == 'X') walls++;
				}
			}

//			System.out.println("n = " + n);
			length = (int) Math.pow(2, Math.pow(n, 2)) - 1;
//			System.out.println("length = " + length + " => " + Integer.toString(length, 2));
			
			System.out.println(process());
			
		}
		
	}
	
	private static int process() {
		
		int max = 0;
		int count = 0;
		
		for (int k = length; k >= 0; k--) {
			count = isPossible(table, k);
		
			
			
			if (count != -1) {
//				print();
				
				if (count > max) max = count;
				
			}
		}
		
		
		return max;
	}


//	private static void print() {
//		System.out.println("positions:");
//		for (int k = 0; k < n; k++) {
//			for (int j = 0; j < n; j++) {
//				System.out.print(positions[k][j]);
//			}
//			System.out.println();
//		}
//		System.out.println("walls:");
//		for (int k = 0; k < n; k++) {
//			for (int j = 0; j < n; j++) {
//				System.out.print(table[k][j]);
//			}
//			System.out.println();
//		}
//		
//	}

	private static int isPossible(char[][] table, int k) {
		int number = 0;
		
		String i = Integer.toString(k, 2); 
		for (int j = i.length(); j < n * n; j++) {
			i = '0' + i;
		}
		
		
		for (int j = 0; j < n; j++) {
			for (int l = 0; l < n; l++) {
				positions[j][l] = i.charAt((j * n) + l);
				if (positions[j][l] == '1') {
					number++;
					
					if (table[j][l] == 'X') return -1;
					
				} else positions[j][l] = '0';
			}
		}

		if (number + walls > length) {
//			System.out.println('.');
			return -1;
		}
		
		
		for (int j = 0; j < n; j++) {
			for (int l = 0; l < n; l++) {
				if (positions[j][l] == '1') {
					
					if (isThreatened(j, l, table)) return -1;
					
				}
			}
		}
		
//		System.out.println("i: " + i);
		
		return number;
	}


	private static boolean isThreatened(int y, int x, char[][] table) {
		
		for (int i = y + 1; i < n; i++) {
			if (table[i][x] == 'X') break;
			if (positions[i][x] == '1') return true;
		}
		
		for (int i = y - 1; i >= 0; i--) {
			if (table[i][x] == 'X') break;
			if (positions[i][x] == '1') return true;
		}
		
		for (int j = x + 1; j < n; j++) {
			if (table[y][j] == 'X') break;
			if (positions[y][j] == '1') return true;
		}
		
		for (int j = x - 1; j >= 0; j--) {
			if (table[y][j] == 'X') break;
			if (positions[y][j] == '1') return true;
		}
		
		
		return false;
	}


	
	
}
